/**
 *
 */
package org.yabam.dao.impl.fake;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.yabam.dao.DefaultDAO;
import org.yabam.model.Owner;

/**
 * @author brlau69n
 *
 */
public class OwnerDAOImpl implements DefaultDAO<Owner> {

	private static final OwnerDAOImpl INSTANCE = new OwnerDAOImpl();

	private OwnerDAOImpl() {
	}

	public static final OwnerDAOImpl getInstance() {
		return INSTANCE;
	}

	private static Map<String, Owner> owners = new HashMap<String, Owner>();

	static {
		owners.put("brisssou", new Owner("brisssou", "Brice Laurencin", "blababla@blabla.com", "pistolero"));
	}

	/**
	 *
	 * @see org.yabam.dao.DefaultDAO#delete(org.yabam.model.Owner)
	 */
	@Override
	public void delete(Owner owner) {
		owners.remove(owner.getLogin());
	}

	/**
	 *
	 * @see org.yabam.dao.DefaultDAO#get(java.lang.Object)
	 */
	@Override
	public Owner get(Object userName) {
		return owners.get(userName);
	}

	/**
	 *
	 * @see org.yabam.dao.DefaultDAO#getAll()
	 */
	@Override
	public List<Owner> getAll() {
		return new ArrayList<Owner> (owners.values());
	}

	/**
	 *
	 * @see org.yabam.dao.DefaultDAO#saveOrUpdate(org.yabam.model.Owner)
	 */
	@Override
	public void saveOrUpdate(Owner owner) {
		owners.put(owner.getLogin(), owner);
	}

}
